class Stack:
    def __init__(self):
        self.stark = []
    def push(self,element):
        self.stark.append(element)
    def pop(self):
        return self.stark.pop()
    def get_top(self):
        if len(self.stark) == 0:
            return None
        else:
            return self.stark[-1]
    def is_empty(self):
        return len(self.stark) == 0


"""
queue模块保证系统安全
deque 用来解算法题
"""
from collections import deque


class Queue:
    def __init__(self,size=100):
        self.queue = [0 for i in range(size)]
        self.size = size
        self.rear = 0 # 队尾 进队这个值+1
        self.front = 0 # 队首 出队 +1
    def push(self,element):
        if not self.is_filled():
            self.rear = (self.rear + 1) % self.size
            self.queue[self.rear] = element
        else:
            raise IndexError("Queue is Filled")
    def pop(self):
        if not self.is_empty():
            self.front = (self.front + 1) % self.size
            return self.queue[self.front]
        else:
            raise IndexError("Queue is Empty")
    # 判断队空
    def is_empty(self):
        return self.rear == self.front

    def is_filled(self):
        return (self.rear + 1) % self.size == self.front
    def cat(self):
        print(self.queue[self.front:self.rear])





